import { defineStore } from "pinia";
import { computed, ref } from "vue";

import { TMerchantInfo, TMerchantStaff } from "@/global";

const useMerchant = defineStore("merchant", () => {
  // 商户内容
  const merchantData = ref<TMerchantInfo>();
  // 商户员工
  const merchantStaff = ref<TMerchantStaff>();

  // 状态: 0 未加载 ｜ 1 已加载
  const merchantLoadStatus = ref(0);

  const merchantId = computed(
    () => merchantData.value?.id || merchantStaff.value?.merchant_id
  );

  return {
    merchantId,
    merchantData,
    merchantStaff,
    merchantLoadStatus,
  };
});

export default useMerchant;
